package HLLib.control.HLGrid6;

import HLLib.base.HLGraphics;
import HLLib.base.HLGraphics_H;
import HLLib.base.HLImage;
import HLLib.base.HLString;

public class HLGrid6Item implements HLGraphics_H {
    HLImage icon;

    HLString text;

    public HLImage iconText;

    public HLImage iconSelectedText;

    public HLGrid6Item(HLImage icon, HLImage iconText, HLImage iconSelectedText) {
        this.icon = icon;
        this.iconText = iconText;
        this.iconSelectedText = iconSelectedText;

    }

    public HLGrid6Item(HLImage icon, String text) {
        this.icon = icon;
        if (text != null) {
            this.text = new HLString(text);
        }
    }

    public void Render(HLGraphics g, int rectX, int rectY, int rectWidth, int rectHeight, boolean isSelected) {
        if (icon != null) {
            int textHeight = HLGraphics.StringHeight() + 2;
            if (iconText != null) {
                textHeight = iconText.GetHeight();
                g.DrawImageAdjustable(icon, rectX, rectY, rectWidth, rectHeight - textHeight + 8, TRANS_NONE, HCENTER_BOTTOM);
            } else {
                g.DrawImageAdjustable(icon, rectX, rectY, rectWidth, rectHeight - textHeight - 2, TRANS_NONE, HCENTER_BOTTOM);
            }
        }
        if (text != null) {
            g.DrawStringAdjustable(text, 0xffffff, 0, rectX, rectY, rectWidth, rectHeight - 2, TEXT_STYLE_NORMAL, HCENTER_BOTTOM);
        }
        if (iconText != null) {
            HLImage imageText = isSelected ? iconSelectedText : iconText;
            g.DrawImageAdjustable(imageText, rectX, rectY, rectWidth, rectHeight, TRANS_NONE, HCENTER_BOTTOM);
        }

    }
}
